package worker;

import java.io.IOException;

import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;

import data.Data;

public class InsertContent extends Thread {
	long timeout;
	Thread[] group;
	BasicDBObject obj;
	
	public InsertContent(long timeout, Thread[] group,BasicDBObject obj) {
		this.timeout = timeout;
		this.group = group;
		this.obj = obj;
		this.start();
	}

	@SuppressWarnings("deprecation")
	public void run() {
		try {
			InsertContent.sleep(timeout);
			DBCollection coll = Data.data("wordpress");
			coll.insert(obj);
		} catch (InterruptedException e) {
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			for (int i = 0; i < group.length; i++) {
				try {
					group[i].suspend();
					group[i].stop();
				} catch (Exception e2) {
					e2.printStackTrace();
				}
			}

		}

	}
}
